#include<bits/stdc++.h>
using namespace std;

struct Cars
{
    int st;
    int v,a;//add
};

struct place
{
    double be,en;
};

bool cmp(place x,place y)
{
    return x.en<y.en||(x.en==y.en&&x.be<y.be);
}

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T; cin>>T;
    while(T--)
    {
        int n,m,len,V;
        cin>>n>>m>>len>>V;
        Cars c[n];
        for(int i=0; i<n; i++)
            cin>>c[i].st>>c[i].v>>c[i].a;
        vector<place>D;
        int det[m];
        for(int i=0; i<m; i++) cin>>det[i];
        //all on
        int num=0;
        for(int i=0; i<n; i++)
        {
            place p;
            if(c[i].a!=0)
                p.be=1.0*(V*V-c[i].v*c[i].v)/2/c[i].a+c[i].st;
            else
            {
                if(c[i].v>V)
                    p.be=c[i].st;
                else
                    continue;
            }
            //if(p.be>len||p.be<0) continue;
            if(c[i].a>=0) p.en=len;
            else p.en=p.be,p.be=c[i].st;
            //cout<<i+1<<' '<<p.be<<' '<<p.en<<endl;
            for(int j=0; j<m; j++)
                if(det[j]>=p.be&&det[j]<=p.en)
                {
                    D.push_back(p);
                    num++;
                    break;
                }
        }
        cout<<num<<' ';

        //part on
        if(num==0)
        {
            cout<<m<<endl;
            continue;
        }
        sort(D.begin(),D.end(),cmp);
        num=1;
        int i=0;
        while(det[i]<D[0].en&&i<m)
            i++;
        i--;
        int dd=det[i];
        for(int j=0; j<D.size(); j++)
        {
            if(dd>=D[j].be&&dd<=D[j].en)
                continue;
            while(det[i]<D[j].en&&i<m)
                i++;
            i--;
            dd=det[i];
            num++;
        }
        cout<<m-num<<endl;
    }
    return 0;
}
